package com.aaa.reflect;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/8/18 9:06
 * @description：测试Class类
 * @modified By：
 * @version: 1.0
 */
public class ClassTest {
    public static void main(String[] args) {
        //1、Class.forName
       /* try {
            Class<?> clazz1 = Class.forName("com.aaa.reflect.Person");
            System.out.println(clazz1);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }*/
        //2、通过对象.getClass
      /*  Person person = new Person();
        Class<? extends Person> clazz2 = person.getClass();
        System.out.println(clazz2);*/
        //3、类.class
        Class<Person> clazz3 = Person.class;
        System.out.println(clazz3);

       /* //通过反射Class 的newInstance方法实例化对象
        try {
            Person person1 = clazz3.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }*/

      /*  String name = clazz3.getName();
        System.out.println(name);
        Annotation[] annotations = clazz3.getAnnotations();
        for (Annotation annotation : annotations) {
            System.out.println("注解："+annotation);
        }

        Class<?>[] interfaces = clazz3.getInterfaces();
        for (Class<?> anInterface : interfaces) {
            System.out.println("接口："+anInterface);
        }
        Class<? super Person> superclass = clazz3.getSuperclass();
        System.out.println("父类"+superclass);*/

    }
}
